package com.pond.pond.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.pond.common.log.annotation.Log;
import com.pond.common.log.enums.BusinessType;
import com.pond.common.security.annotation.RequiresPermissions;
import com.pond.pond.domain.FinanceRecord;
import com.pond.pond.service.IFinanceRecordService;
import com.pond.common.core.web.controller.BaseController;
import com.pond.common.core.web.domain.AjaxResult;
import com.pond.common.core.utils.poi.ExcelUtil;
import com.pond.common.core.web.page.TableDataInfo;

/**
 * 财务记录Controller
 * 
 * @author ruoyi
 * @date 2025-05-20
 */
@RestController
@RequestMapping("/finace")
public class FinanceRecordController extends BaseController
{
    @Autowired
    private IFinanceRecordService financeRecordService;

    /**
     * 查询财务记录列表
     */
    @RequiresPermissions("pond:finace:list")
    @GetMapping("/list")
    public TableDataInfo list(FinanceRecord financeRecord)
    {
        startPage();
        List<FinanceRecord> list = financeRecordService.selectFinanceRecordList(financeRecord);
        return getDataTable(list);
    }

    /**
     * 导出财务记录列表
     */
    @RequiresPermissions("pond:finace:export")
    @Log(title = "财务记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FinanceRecord financeRecord)
    {
        List<FinanceRecord> list = financeRecordService.selectFinanceRecordList(financeRecord);
        ExcelUtil<FinanceRecord> util = new ExcelUtil<FinanceRecord>(FinanceRecord.class);
        util.exportExcel(response, list, "财务记录数据");
    }

    /**
     * 获取财务记录详细信息
     */
    @RequiresPermissions("pond:finace:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(financeRecordService.selectFinanceRecordById(id));
    }

    /**
     * 新增财务记录
     */
    @RequiresPermissions("pond:finace:add")
    @Log(title = "财务记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FinanceRecord financeRecord)
    {
        return toAjax(financeRecordService.insertFinanceRecord(financeRecord));
    }

    /**
     * 修改财务记录
     */
    @RequiresPermissions("pond:finace:edit")
    @Log(title = "财务记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FinanceRecord financeRecord)
    {
        return toAjax(financeRecordService.updateFinanceRecord(financeRecord));
    }

    /**
     * 删除财务记录
     */
    @RequiresPermissions("pond:finace:remove")
    @Log(title = "财务记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(financeRecordService.deleteFinanceRecordByIds(ids));
    }
}
